home *** CD-ROM | disk | FTP | other *** search
/ Amoszine PD Edition 0 / Amoszine PD Edition 0.adf / SOURCE_CODE / joy_text.AMOS / joy_text.amosSourceCode < prev    next >
AMOS Source Code  |  1993-02-25  |  3KB  |  123 lines

  1. Rem   **************************************** 
  2. Rem   ***     Entering text using the      *** 
  3. Rem   ***            JOYSTICK              *** 
  4. Rem   ***         By Graham Lund           *** 
  5. Rem   **************************************** 
  6. '
  7. Screen Open 0,320,256,4,Lowres
  8. Curs Off : Flash Off : Hide 
  9. Palette 0,$FFF,$11F,$FF0
  10. Paper 0 : Cls 
  11. '
  12. Rem   Set up a string to hold the letters to be used 
  13. '
  14.   LETTR$="ABCDEFGHIJKLMNOPQRSTUVWXYZ., "
  15. '
  16. Rem   Draw and grab a bob to be used to highlight chosen letter
  17. '
  18.   Ink 3,0
  19.   Box 0,0 To 23,10
  20.   Get Bob 1,0,0 To 24,11
  21.   Cls 0
  22. '
  23. Rem   Enter programmes title and explain how to choose a letter
  24. '
  25.   Pen 3
  26.   Locate 0,4 : Centre "ENTERING TEXT USING JOYSTICK"
  27.   Pen 2
  28.   Locate 0,25 : Centre "Highlight letter by moving joystick."
  29.   Locate 0,27 : Centre "Press FIRE to select letter."
  30. '
  31. Rem   Place the letters on the screen
  32. '
  33.   Pen 1
  34.   Locate 4,17 : Print "A  B  C  D  E  F  G  H  I  J"
  35.   Locate 4,19 : Print "K  L  M  N  O  P  Q  R  S  T"
  36.   Locate 4,21 : Print "U  V  W  X  Y  Z  .  ,    end"
  37. '
  38. Rem   Draw a box to hold the name
  39. '
  40.   Locate 0,8 : Centre "Name Box."
  41.   Ink 2 : Box 100,74 To 200,92
  42.   Ink 3 : Box 99,73 To 201,93
  43.   Ink 2 : Box 98,72 To 202,94
  44. '
  45.   Proc _ENTERNAME
  46.   End 
  47. '
  48. Procedure _ENTERNAME
  49. Rem  List the shared variables 
  50. '
  51.   Shared N$
  52.   Shared UP,LFT,DWN,RGHT,BX,BY,W,NAMEEND
  53. '
  54. Rem  Enter initial values for the shared variables 
  55. '
  56.   UP=1 : LFT=1 : DWN=0 : RGHT=0 : W=1 : NAMEEND=0
  57.   BX=24 : BY=134
  58.   NAME$=""
  59.   LETTER=0
  60. '
  61. Rem  Place the bob grabbed above around the first letter 
  62. '
  63.   Bob 1,BX,BY,1
  64.   Pen 3
  65. '
  66. Rem  This part calls the procedure _PICKLETTER repeatedly until
  67. Rem  seven letters have been chosen at which point the repeat
  68. Rem  until loop is completed. The letters are entered into the 
  69. Rem  string NAME$ by adding the string N$ to it each time a
  70. Rem  letter has been chosen and the string is displayed. 
  71. '
  72. Repeat 
  73.   Proc _PICKLETTER
  74.   NAME$=NAME$+N$
  75.   Locate 15,10 : Print NAME$
  76.   Inc LETTER
  77.   If NAMEEND=1 Then LETTER=7
  78. Until LETTER=7
  79. End Proc
  80. '
  81. Procedure _PICKLETTER
  82.   Shared N$,LETTR$
  83.   Shared UP,LFT,DWN,RGHT,BX,BY,W,NAMEEND
  84. '
  85. Rem  This Repeat - Until loop reads the joystick and will only 
  86. Rem  move the bob if the move is allowed by the values held in 
  87. Rem  UP DWN LFT and RGHT 
  88. '
  89. Q=0 : N$=""
  90. Repeat 
  91.   If LFT=0 and Jleft(1)
  92.     BX=BX-24 : RGHT=0 : Dec W
  93.   Else If RGHT=0 and Jright(1)
  94.     Add BX,24 : LFT=0 : Inc W
  95.   Else If UP=0 and Jup(1)
  96.     BY=BY-16 : DWN=0 : W=W-10
  97.   Else If DWN=0 and Jdown(1)
  98.     Add BY,16 : UP=0 : Add W,10
  99.       End If 
  100.     End If 
  101.   End If 
  102. End If 
  103.   Bob 1,BX,BY,1
  104.   Wait 10
  105.   If BX=24 Then LFT=1
  106.   If BX=240 Then RGHT=1
  107.   If BY=134 Then UP=1
  108.   If BY=166 Then DWN=1
  109.   If Fire(1) Then Bell 70 : Q=1
  110. Until Q=1
  111. '
  112. Rem  A value of 30 for W means no more letters are needed
  113. Rem  so the NAMEEND variable is incremented
  114. '
  115.   If W=30 Then NAMEEND=1 : N$=""
  116. '
  117. Rem  The correct letter is retrieved from the LETTR$ string and
  118. Rem  fed into the N$ string
  119. '
  120.   If W<30
  121.     N$=Mid$(LETTR$,W,1)
  122.   End If 
  123. End Proc